// 添加 分类 模态框
import React, {useRef} from 'react';
import {Form, message, Modal} from 'antd';
import ProForm, { ProFormText, ProFormSelect, ProFormTextArea, ProFormDigit } from '@ant-design/pro-form';
import {addFeedbackCategory} from "@/services/ant-design-pro/customerService";


const AddCategory = (props) => {
  const { setIsShowCategoryModal,isShowCategoryModal,record } = props
  const [form] = Form.useForm()

  return (
    <div>
      <Modal
        visible={isShowCategoryModal}
        title='添加分类'
        onCancel={()=>{setIsShowCategoryModal(!isShowCategoryModal)}}
        onOk={()=>{
          form.validateFields().then( async value => {
            console.log('1111',value);
            const {nickname,sort} = value
            await addFeedbackCategory({nickname})
            message.success('添加分类成功')
          })
          setIsShowCategoryModal(!isShowCategoryModal)
        }}
      >
        <ProForm
          form={form}
          initialValues={record}
          layout={'horizontal'}
          labelCol={{span:4}}
          wrapperCol={{span:14}}
          submitter={false}
        >
          <ProFormText
            name="nickname"
            label="分类名称"
            placeholder="请输分类名称"
          />
          <ProFormDigit
            width={100}
            name="sort"
            label="排序"
          />
        </ProForm>
      </Modal>
    </div>
  );
};

export default AddCategory;
